package com.tjn.enum_;

/**
 * 使用枚举来写季节的类
 * 第一种方法
 * 自定义类实现枚举
 */
public class Enumeration02 {
    public static void main(String[] args) {
        System.out.println(Season01.SPRING);
        System.out.println(Season01.SUMMER);

    }
}

/*
规则：
1.将构造器私有化，这样就不能直接被new对象了
2.去掉setXXX方法，这样属性值就不会被修改
3.在season内部直接创造固定的对象
4.可以加入final修饰符，这样对象无法被修改
 */

class Season01{
    private String name;
    private String desc;

    public static final Season01 SPRING = new Season01("春天", "温暖");
    public static final Season01 SUMMER = new Season01("夏天", "炎热");
    public static final Season01 AUTUMN = new Season01("秋天", "凉爽");
    public static final Season01 WINTER = new Season01("冬天", "寒冷");

    private Season01(String name, String desc) {
        this.name = name;
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    // toString()方法，输出对象时，会自动调用toString()方法，输出对象的属性值
    @Override
    public String toString() {
        return "Season01{" +
                "name='" + name + '\'' +
                ", desc='" + desc + '\'' +
                '}';
    }
}